﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using RED_NET_Core.Helper;
namespace RED_NET_Core.Entity
{
   public class Comment
   {
       #region [Private member]
       private int _id;
       private int _uId;
       private bool _level;//评论对象类型（注：0日志，1图片）
       private int _idTo;
       private DateTime _addTime;
       private string _tent;
       private string _userName;
       #endregion
       #region [Properties Of Album]
       public int Id
       {
           get { return _id; }
           set { _id = value; }
       }
       public int UId
       {
           get { return _uId; }
           set { _uId = value; }
       }
       public bool Level
       {
           get { return _level; }
           set { _level = value; }
       }
       public int IdTo
       {
           get { return _idTo; }
           set { _idTo = value; }
       }
       public DateTime AddTime
       {
           get { return _addTime; }
           set { _addTime = value; }
       }
       public string Tent
       {
           get { return _tent; }
           set { _tent = value; }
       }
       public string UserName
       {
           get { return _userName; }
           set { _userName = value; }
       }
       #endregion
       public int AddItem()
       {
           int _id = -1;
           SqlParameter[] _param = new SqlParameter[6];
           _param[0] = new SqlParameter("@UId", _uId.ToString());
           _param[1] = new SqlParameter("@IdTo", _idTo.ToString());
           _param[2] = new SqlParameter("@Tent", _tent.ToString());
           _param[3] = new SqlParameter("@Level", _level.ToString());
           _param[4] = new SqlParameter("@AddTime", _addTime.ToString());
           _param[5] = new SqlParameter("@UserName", _userName.ToString());
           string _smdStr = "insert into _Comment(_UId,_IdTo,_Tent,_Level,_AddTime,_UserName) values(@UId,@IdTo,@Tent,@Level,@AddTime,@UserName) SELECT   SCOPE_IDENTITY()   as   '_Id'";
           OwnSqlHelper _shp = new OwnSqlHelper();
            try
           {
               _id = Int32.Parse(_shp.ExecuteScalar(_smdStr,_param));
           }
           catch (Exception ex)
           {
            throw ex;
           }
           return _id;
       }
   }
}
